package com.lagou;

import com.lagou.bean.ConsumerTaskA;
import com.lagou.bean.ConsumerTaskB;
import com.lagou.bean.ConsumerTaskC;
import org.apache.dubbo.config.spring.context.annotation.EnableDubbo;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.PropertySource;

import java.io.IOException;
import java.util.concurrent.*;

public class AnnotationConsumerMain {
    public static void main(String[] args) throws IOException, InterruptedException {
        AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(ConsumerConfiguration.class);
        context.start();
        //定义一个线程池
        ThreadPoolExecutor  executor=new ThreadPoolExecutor(5,10,3000, TimeUnit.MILLISECONDS,
                new LinkedBlockingQueue<Runnable>());
        while (true) {
            Future<?>resultA=executor.submit(context.getBean(ConsumerTaskA.class));
            Future<?>resultB=executor.submit(context.getBean(ConsumerTaskB.class));
            Future<?>resultC=executor.submit(context.getBean(ConsumerTaskC.class));
        }
    }

    @Configuration
    @PropertySource("classpath:/dubbo-consumer.properties")
    @EnableDubbo(scanBasePackages = "com.lagou.bean")
    @ComponentScan("com.lagou.bean")
    static class ConsumerConfiguration {

    }
}
